using System;
using System.Configuration;

using Utility;

namespace MapsJavascript
{
	public abstract class JavascriptFactory
	{
		public JavascriptFactory() {
		}

		public abstract JavascriptObject createControl(Maps.Control control);
		public abstract JavascriptObject createLatLng(Maps.LatLng point);
		public abstract JavascriptObject createOverlay(Maps.Map map, Maps.Overlay overlay);
		public abstract JavascriptObject createIcon(Maps.Icon icon);
		public abstract JavascriptObject createInfoWindowTab(Maps.InfoWindowTab tab);
		public abstract JavascriptFunction createClientGeocoderFunc(string address, string geocoder, string function);
		public abstract JavascriptObject createMapOverlays(Maps.Map map);
		public abstract JavascriptFunction createMapFunc(Maps.Map map);

		public static JavascriptFactory create() {
			string service = ConfigurationSettings.AppSettings["map_service"];
			if(service == "Google") {
				return new MapsJavascript.GoogleMapsFactory();
			}
			else {
				throw new Exception("Unknown map service: " + service);
			}
		}
	}
}
